home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / PInterfaces / ATA.p < prev    next >
Encoding:
Text File  |  1996-05-06  |  50.8 KB  |  996 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        ATA.p
  3.  
  4.      Contains:    ATA (PC/AT Attachment) Interfaces
  5.  
  6.      Version:    System 7.5
  7.                  Package:    Universal Interfaces 2.1.3
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT ATA;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __ATA__}
  30. {$SETC __ATA__ := 1}
  31.  
  32. {$I+}
  33. {$SETC ATAIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36. {$IFC UNDEFINED __TYPES__}
  37. {$I Types.p}
  38. {$ENDC}
  39. {$IFC UNDEFINED __MIXEDMODE__}
  40. {$I MixedMode.p}
  41. {$ENDC}
  42.  
  43. {$PUSH}
  44. {$ALIGN MAC68K}
  45. {$LibExport+}
  46.  
  47. {  This is the structure used for the AT Interface core routines below  }
  48.  
  49. CONST
  50.     kATATrap                    = $AAF1;                        {  Manager trap number <This should be defined in Traps.h> }
  51.     kATAPBVers1                    = $01;                            {  parameter block version number 1 }
  52.     kATAPBVers2                    = $02;                            {  parameter block version number for structures }
  53.     kATAPBVers3                    = $03;                            {  parameter block version for ATA times }
  54.     kATADefaultBlockSize        = 512;                            {  default block size }
  55.  
  56. {  Used to determine the presence of traps }
  57.     kFSMTrap                    = $AC;
  58.     mDQEChanged                    = 1;                            {  DQE has changed  }
  59.  
  60. {  Task file definition ••• Error Register ••• }
  61.     bATABadBlock                = 7;                            {  bit number of bad block error bit }
  62.     bATAUncorrectable            = 6;                            {  bit number of uncorrectable error bit }
  63.     bATAMediaChanged            = 5;                            {  bit number of media changed indicator }
  64.     bATAIDNotFound                = 4;                            {  bit number of ID not found error bit }
  65.     bATAMediaChangeReq            = 3;                            {  bit number of media changed request }
  66.     bATACommandAborted            = 2;                            {  bit number of command abort bit }
  67.     bATATrack0NotFound            = 1;                            {  bit number of track not found }
  68.     bATAAddressNotFound            = 0;                            {  bit number of address mark not found }
  69.     mATABadBlock                = $80;                            {  Bad Block Detected }
  70.     mATAUncorrectable            = $40;                            {  Uncorrectable Data Error }
  71.     mATAMediaChanged            = $20;                            {  Media Changed Indicator (for removable) }
  72.     mATAIDNotFound                = $10;                            {  ID Not Found }
  73.     mATAMediaChangeReq            = $08;                            {  Media Change Requested (NOT IMPLEMENTED) }
  74.     mATACommandAborted            = $04;                            {  Aborted Command }
  75.     mATATrack0NotFound            = $02;                            {  Track 0 Not Found }
  76.     mATAAddressNotFound            = $01;                            {  Address Mark Not Found }
  77.  
  78. {  Task file definition ••• ataTFSDH Register ••• }
  79.     mATAHeadNumber                = $0F;                            {  Head Number (bits 0-3)  }
  80.     mATASectorSize                = $A0;                            {  bit 7=1; bit 5 = 01 (512 sector size) <DP4> }
  81.     mATADriveSelect                = $10;                            {  Drive (0 = master, 1 = slave)  }
  82.     mATALBASelect                = $40;                            {  LBA mode bit (0 = chs, 1 = LBA) }
  83.  
  84. {  Task file definition ••• Status Register ••• }
  85.     bATABusy                    = 7;                            {  bit number of BSY bit }
  86.     bATADriveReady                = 6;                            {  bit number of drive ready bit }
  87.     bATAWriteFault                = 5;                            {  bit number of write fault bit }
  88.     bATASeekComplete            = 4;                            {  bit number of seek complete bit }
  89.     bATADataRequest                = 3;                            {  bit number of data request bit }
  90.     bATADataCorrected            = 2;                            {  bit number of data corrected bit }
  91.     bATAIndex                    = 1;                            {  bit number of index mark }
  92.     bATAError                    = 0;                            {  bit number of error bit }
  93.     mATABusy                    = $80;                            {  Unit is busy }
  94.     mATADriveReady                = $40;                            {  Unit is ready }
  95.     mATAWriteFault                = $20;                            {  Unit has a write fault condition }
  96.     mATASeekComplete            = $10;                            {  Unit seek complete }
  97.     mATADataRequest                = $08;                            {  Unit data request }
  98.     mATADataCorrected            = $04;                            {  Data corrected }
  99.     mATAIndex                    = $02;                            {  Index mark - NOT USED }
  100.     mATAError                    = $01;                            {  Error condition - see error register }
  101.  
  102. {  ATA Command Opcode definition }
  103.     kATAcmdWORetry                = $01;                            {  Without I/O retry option }
  104.     kATAcmdNOP                    = $0000;                        {  NOP operation - media detect }
  105.     kATAcmdRecal                = $0010;                        {  Recalibrate command  }
  106.     kATAcmdRead                    = $0020;                        {  Read command  }
  107.     kATAcmdReadLong                = $0022;                        {  Read Long command }
  108.     kATAcmdWrite                = $0030;                        {  Write command  }
  109.     kATAcmdWriteLong            = $0032;                        {  Write Long }
  110.     kATAcmdReadVerify            = $0040;                        {  Read Verify command  }
  111.     kATAcmdFormatTrack            = $0050;                        {  Format Track command  }
  112.     kATAcmdSeek                    = $0070;                        {  Seek command  }
  113.     kATAcmdDiagnostic            = $0090;                        {  Drive Diagnostic command  }
  114.     kATAcmdInitDrive            = $0091;                        {  Init drive parameters command  }
  115.     kATAcmdReadMultiple            = $00C4;                        {  Read multiple }
  116.     kATAcmdWriteMultiple        = $00C5;                        {  Write multiple }
  117.     kATAcmdSetRWMultiple        = $00C6;                        {  Set Multiple for Read/Write Multiple }
  118.     kATAcmdReadDMA                = $00C8;                        {  Read DMA (with retries) }
  119.     kATAcmdWriteDMA                = $00CA;                        {  Write DMA (with retries) }
  120.     kATAcmdMCAcknowledge        = $00DB;                        {  Acknowledge media change - removable }
  121.     kATAcmdStandbyImmed            = $00E0;                        {  Standby Immediate }
  122.     kATAcmdIdleImmed            = $00E1;                        {  Idle Immediate }
  123.     kATAcmdStandby                = $00E2;                        {  Standby }
  124.     kATAcmdIdle                    = $00E3;                        {  Idle }
  125.     kATAcmdReadBuffer            = $00E4;                        {  Read sector buffer command  }
  126.     kATAcmdCheckPowerMode        = $00E5;                        {  Check power mode command    <04/04/94> }
  127.     kATAcmdSleep                = $00E6;                        {  Sleep }
  128.     kATAcmdWriteBuffer            = $00E8;                        {  Write sector buffer command  }
  129.     kATAcmdDriveIdentify        = $00EC;                        {  Identify Drive command  }
  130.     kATAcmdSetFeatures            = $00EF;                        {  Set Features }
  131.  
  132. {  Set feature command opcodes }
  133.     kATAEnableWriteCache        = $02;                            {         Enable write cache }
  134.     kATASetTransferMode            = $03;                            {         Set transfer mode }
  135.     kATASetPIOMode                = $08;                            {         PIO Flow Control Tx Mode bit }
  136.     kATAEnableECC                = $88;                            {         ECC enable }
  137.     kATAEnableRetry                = $99;                            {         Retry enable }
  138.     kATAEnableReadAhead            = $AA;                            {         Read look-ahead enable }
  139.  
  140. {  ATA Device ID codes }
  141.     kATAInvalidDeviceID            = -1;
  142.     kATAMasterDeviceID            = 0;
  143.     kATASlaveDeviceID            = 1;
  144.  
  145. {  Device Register Images  (8 bytes)  }
  146.  
  147. TYPE
  148.     ataTaskFilePtr = ^ataTaskFile;
  149.     ataTaskFile = RECORD
  150.         ataTFFeatures:            SInt8;                                    {  <-> Error(R) or ataTFFeatures(W) register image  }
  151.         ataTFCount:                SInt8;                                    {  <-> Sector count/remaining  }
  152.         ataTFSector:            SInt8;                                    {  <-> Sector start/finish  }
  153.         ataTFReserved:            SInt8;                                    {  reserved                     }
  154.         ataTFCylinder:            UInt16;                                    {  <-> ataTFCylinder (Big endian)  }
  155.         ataTFSDH:                SInt8;                                    {  <-> ataTFSDH register image }
  156.         ataTFCommand:            SInt8;                                    {  <-> Status(R) or Command(W) register image  }
  157.     END;
  158.  
  159. {  ATA Manager Function Code Definition }
  160.  
  161. CONST
  162.     kATAMgrNOP                    = $00;                            {  No Operation }
  163.     kATAMgrExecIO                = $01;                            {  Execute ATA I/O }
  164.     kATAMgrBusInquiry            = $03;                            {  Bus Inquiry }
  165.     kATAMgrQRelease                = $04;                            {  I/O Queue Release }
  166.     kATAMgrAbort                = $10;                            {  Abort command }
  167.     kATAMgrBusReset                = $11;                            {  Reset ATA bus }
  168.     kATAMgrRegAccess            = $12;                            {  Register Access }
  169.     kATAMgrDriveIdentify        = $13;                            {  Drive Identify            <DP03/10/94> }
  170.     kATAMgrDriverLoad            = $82;                            {  Load driver from either Media, ROM, etc. }
  171.     kATAMgrDriveRegister        = $85;                            {  Register a driver        <4/18/94> }
  172.     kATAMgrFindDriverRefnum        = $86;                            {  lookup a driver refnum    <4/18/94> }
  173.     kATAMgrRemoveDriverRefnum    = $87;                            {  De-register a driver    <4/18/94> }
  174.     kATAMgrModifyEventMask        = $88;                            {  Modify driver event mask }
  175.     kATAMgrDriveEject            = $89;                            {  Eject the drive        <8/1/94> }
  176.     kATAMgrGetDrvConfiguration    = $8A;                            {  Get device configuration    <8/6/94> }
  177.     kATAMgrSetDrvConfiguration    = $8B;                            {  Set device configuration <8/6/94> }
  178.     kATAMgrGetLocationIcon        = $8C;                            {  Get card location icon    <SM4> }
  179.     kATAMgrManagerInquiry        = $90;                            {  Manager Inquiry }
  180.     kATAMgrManagerInit            = $91;                            {  Manager initialization }
  181.     kATAMgrManagerShutdown        = $92;                            {  Manager ShutDown }
  182.  
  183. {  'ATAFlags' field of the PB header definition }
  184.     bATAFlagUseConfigSpeed        = 15;                            {  bit number of use default speed flag }
  185.     bATAFlagByteSwap            = 14;                            {  bit number of byte swap flag }
  186.     bATAFlagIORead                = 13;                            {  bit number of I/O read flag }
  187.     bATAFlagIOWrite                = 12;                            {  bit number of I/O write flag }
  188.     bATAFlagImmediate            = 11;                            {  bit number of immediate flag }
  189.     bATAFlagQLock                = 10;                            {  bit number of que lock on error }
  190.     bATAFlagScatterGather1        = 9;                            {  bit number of scatter gather }
  191.     bATAFlagScatterGather0        = 8;                            {  bit numbers of scatter gather }
  192.     bATAFlagUseDMA                = 7;                            {  bit number of use DMA flag }
  193.     bATAFlagProtocol1            = 5;                            {  bit number of scatter gather }
  194.     bATAFlagProtocol0            = 4;                            {  bit numbers of protocol specifier }
  195.     bATAFlagTFRead                = 3;                            {  bit number of register update }
  196.     bATAFlagLEDEnable            = 0;                            {  bit number of LED enable }
  197.     mATAFlagUseConfigSpeed        = $8000;
  198.     mATAFlagByteSwap            = $4000;                        {  Swap data bytes (read - after; write - before) }
  199.     mATAFlagIORead                = $2000;                        {  Read (in) operation }
  200.     mATAFlagIOWrite                = $1000;                        {  Write (out) operation }
  201.     mATAFlagImmediate            = $0800;                        {  Head of Que; Immediate operation }
  202.     mATAFlagQLock                = $0400;                        {  Manager queue lock on error (freeze the queue) }
  203.     mATAFlagScatterGather1        = $0200;
  204.     mATAFlagScatterGather0        = $0100;                        {  Scatter gather enable }
  205.     mATAFlagScatterGathers        = $0300;                        {  host scatter gather type = currently type 1 supported }
  206.     mATAFlagUseDMA                = $80;
  207.     mATAFlagProtocol1            = $20;                            {  ATAPI protocol indicator <06/15/94> }
  208.     mATAFlagProtocol0            = $10;                            {  PCMCIA protocol indicator <06/15/94> }
  209.     mATAFlagProtocols            = $30;                            {  mask for protocol type field    <06/15/94> }
  210.     mATAFlagTFRead                = $08;                            {  update reg block request upon detection of an error }
  211.     mATAFlagLEDEnable            = $01;                            {  socket LED enable }
  212.  
  213. {  Parameter block header definition - common for all PBs (48 bytes) }
  214.  
  215. TYPE
  216.     ataPBHeaderPtr = ^ataPBHeader;
  217.     ataPBHeader = RECORD
  218.                                                                         {  Start of cloned common header ataPBHdr  }
  219.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  220.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  221.         ataPBVers:                SInt8;                                    {  -->: parameter block version number }
  222.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  223.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  224.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  225.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  226.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  227.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  228.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  229.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  230.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  231.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  232.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  233.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  234.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  235.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  236.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  237.                                                                         {  End of cloned common header ataPBHdr }
  238.     END;
  239.  
  240. {  data request entry structure (16 bytes) }
  241.     IOBlockPtr = ^IOBlock;
  242.     IOBlock = RECORD
  243.         ataPBBuffer:            Ptr;                                    {  -->: Data buffer pointer }
  244.         ataPBByteCount:            UInt32;                                    {  -->: Data transfer length in bytes }
  245.     END;
  246.  
  247. {
  248.  For ATAPI devices the ExtendedPB field is a pointer to the Command Packet
  249.  record which exists of an array of words structured as follows…    <06/15/94>
  250. }
  251.     ATAPICmdPacketPtr = ^ATAPICmdPacket;
  252.     ATAPICmdPacket = RECORD
  253.         atapiPacketSize:        SInt16;                                    {  Size of command packet in bytes    <06/15/94> }
  254.         atapiCommandByte:        ARRAY [0..7] OF SInt16;                    {  The command packet itself    <06/15/94> }
  255.     END;
  256.  
  257. {  Manager parameter block structure (96 bytes) }
  258.     ataIOPBPtr = ^ataIOPB;
  259.     ataIOPB = RECORD
  260.                                                                         {  Start of cloned common header ataPBHdr }
  261.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  262.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  263.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  264.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  265.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  266.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  267.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  268.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  269.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  270.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  271.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  272.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  273.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  274.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  275.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  276.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  277.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  278.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  279.                                                                         {  End of cloned common header ataPBHdr }
  280.         ataPBStatusRegister:    SInt8;                                    {  <--: Last ATA status image }
  281.         ataPBErrorRegister:        SInt8;                                    {  <--: Last ATA error image-valid if lsb of Status set }
  282.         ataPBReserved5:            SInt16;                                    {  Reserved }
  283.         ataPBLogicalBlockSize:    UInt32;                                    {  -->: Blind transfer size per interrupt (Logical block size) }
  284.         ataPBBuffer:            Ptr;                                    {  -->: Data buffer pointer }
  285.         ataPBByteCount:            UInt32;                                    {  -->: Data transfer length in bytes }
  286.         ataPBActualTxCount:        UInt32;                                    {  <--: Actual transfer count }
  287.         ataPBReserved6:            UInt32;                                    {  Reserved }
  288.         ataPBTaskFile:            ataTaskFile;                            {  <->:    Device register images }
  289.         ataPBPacketPtr:            ATAPICmdPacketPtr;                        {  -->: ATAPI packet command block pointer (valid with ATAPI bit set) }
  290.         ataPBReserved7:            ARRAY [0..5] OF SInt16;                    {  Reserved for future expansion }
  291.     END;
  292.  
  293. {
  294.  Parameter block structure for bus and Manager inquiry command
  295.  Manager parameter block structure
  296. }
  297.     ataBusInquiryPtr = ^ataBusInquiry;
  298.     ataBusInquiry = RECORD
  299.                                                                         {  Start of cloned common header ataPBHdr }
  300.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  301.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  302.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  303.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  304.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  305.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  306.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  307.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  308.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  309.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  310.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  311.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  312.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  313.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  314.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  315.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  316.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  317.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  318.                                                                         {  End of cloned common header ataPBHdr }
  319.         ataEngineCount:            UInt16;                                    {  <--: TBD; zero for now }
  320.         ataReserved1:            UInt16;                                    {  Reserved }
  321.         ataDataTypes:            UInt32;                                    {  <--: TBD; zero for now }
  322.         ataIOpbSize:            UInt16;                                    {  <--: Size of ATA IO PB }
  323.         ataMaxIOpbSize:            UInt16;                                    {  <--: TBD; zero for now }
  324.         ataFeatureFlags:        UInt32;                                    {  <--: TBD }
  325.         ataVersionNum:            SInt8;                                    {  <--: Version number for the HBA }
  326.         ataHBAInquiry:            SInt8;                                    {  <--: TBD; zero for now }
  327.         ataReserved2:            UInt16;                                    {  Reserved }
  328.         ataHBAPrivPtr:            UInt32;                                    {  <--: Ptr to HBA private data area }
  329.         ataHBAPrivSize:            UInt32;                                    {  <--: Size of HBA private data area }
  330.         ataAsyncFlags:            UInt32;                                    {  <--: Event capability for callback }
  331.         ataPIOModes:            SInt8;                                    {  <--: PIO modes supported (bit-significant) }
  332.         ataReserved3:            SInt8;                                    {  Reserved }
  333.         ataSingleDMAModes:        SInt8;                                    {  <--: Single Word DMA modes supported (b-sig)     }
  334.         ataMultiDMAModes:        SInt8;                                    {  <--: Multiword DMA modes supported (b-sig) }
  335.         ataReserved4:            ARRAY [0..3] OF UInt32;                    {  Reserved }
  336.         ataReserved5:            ARRAY [0..15] OF SInt8;                    {  TBD }
  337.         ataHBAVendor:            ARRAY [0..15] OF SInt8;                    {  <--: Vendor ID of the HBA }
  338.         ataContrlFamily:        ARRAY [0..15] OF SInt8;                    {  <--: Family of ATA Controller }
  339.         ataContrlType:            ARRAY [0..15] OF SInt8;                    {  <--: Model number of controller }
  340.         ataXPTversion:            ARRAY [0..3] OF SInt8;                    {  <--: version number of XPT }
  341.         ataReserved6:            ARRAY [0..3] OF SInt8;                    {  Reserved }
  342.         ataHBAversion:            ARRAY [0..3] OF SInt8;                    {  <--: version number of HBA }
  343.         ataHBAslotType:            SInt8;                                    {  <--: type of slot }
  344.         ataHBAslotNum:            SInt8;                                    {  <--: slot number of the HBA }
  345.         ataReserved7:            UInt16;                                    {  Reserved }
  346.         ataReserved8:            UInt32;                                    {  Reserved }
  347.     END;
  348.  
  349. {  Manager parameter block structure }
  350.     ataMgrInquiryPtr = ^ataMgrInquiry;
  351.     ataMgrInquiry = RECORD
  352.                                                                         {  Start of cloned common header ataPBHdr }
  353.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  354.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  355.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  356.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  357.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  358.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  359.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  360.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  361.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  362.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  363.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  364.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  365.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  366.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  367.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  368.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  369.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  370.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  371.                                                                         {  End of cloned common header ataPBHdr }
  372.         ataMgrVersion:            NumVersion;                                {  Manager Version information }
  373.         ataMgrPBVers:            SInt8;                                    {  <--: Manager PB version number supported }
  374.         Reserved1:                SInt8;                                    {  Reserved }
  375.         ataBusCnt:                UInt16;                                    {  <--: Number of ATA buses in the system }
  376.         ataDevCnt:                UInt16;                                    {  <--: Total number of ATA devices detected }
  377.         ataPioModes:            SInt8;                                    {  <--: Maximum Programmed I/O speed mode supported }
  378.         Reserved2:                SInt8;                                    {  Reserved }
  379.         ataIOClkResolution:        UInt16;                                    {  <--: IO Clock resolution in nsec (Not supported) }
  380.         ataSingleDMAModes:        SInt8;                                    {  <--: Single Word DMA modes supported     }
  381.         ataMultiDMAModes:        SInt8;                                    {  <--: Multiword DMA modes supported }
  382.         Reserved:                ARRAY [0..15] OF SInt16;                {  Reserved for future expansion }
  383.     END;
  384.  
  385. {
  386.  Parameter block structure for Abort command
  387.  Manager parameter block structure
  388. }
  389.     ataAbortPtr = ^ataAbort;
  390.     ataAbort = RECORD
  391.                                                                         {  Start of cloned common header ataPBHdr }
  392.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  393.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  394.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  395.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  396.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  397.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  398.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  399.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  400.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  401.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  402.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  403.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  404.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  405.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  406.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  407.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  408.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  409.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  410.                                                                         {  End of cloned common header ataPBHdr }
  411.         ataAbortPB:                ataIOPBPtr;                                {  -->: Parameter block to be aborted }
  412.         Reserved:                ARRAY [0..21] OF SInt16;                {  Reserved for future expansion }
  413.     END;
  414.  
  415. {  Manager parameter block structure }
  416.     ATAEventRecPtr = ^ATAEventRec;
  417.     ATAEventRec = RECORD
  418.         ataEventCode:            UInt16;                                    {  --> ATA event code }
  419.         ataPhysicalID:            UInt16;                                    {  --> Physical drive reference }
  420.         ataDrvrContext:            SInt32;                                    {  Context pointer saved by driver }
  421.     END;
  422.  
  423.     ATAClientProcPtr = ProcPtr;  { FUNCTION ATAClient(ataERPtr: ATAEventRecPtr): SInt16; }
  424.  
  425.     ATAClientUPP = UniversalProcPtr;
  426.  
  427. CONST
  428.     uppATAClientProcInfo = $000000E0;
  429.  
  430. FUNCTION NewATAClientProc(userRoutine: ATAClientProcPtr): ATAClientUPP;
  431.     {$IFC NOT GENERATINGCFM }
  432.     INLINE $2E9F;
  433.     {$ENDC}
  434.  
  435. FUNCTION CallATAClientProc(ataERPtr: ATAEventRecPtr; userRoutine: ATAClientUPP): SInt16;
  436.     {$IFC NOT GENERATINGCFM}
  437.     INLINE $205F, $4E90;
  438.     {$ENDC}
  439. {
  440.  Parameter block structure for Driver Register command
  441.  Manager parameter block structure
  442. }
  443.  
  444. TYPE
  445.     ataDrvrRegisterPtr = ^ataDrvrRegister;
  446.     ataDrvrRegister = RECORD
  447.                                                                         {  Start of cloned common header ataPBHdr }
  448.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  449.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  450.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  451.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  452.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  453.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  454.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  455.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  456.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  457.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  458.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  459.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  460.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  461.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  462.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  463.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  464.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  465.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  466.                                                                         {  End of cloned common header ataPBHdr }
  467.         ataDrvrRefNum:            SInt16;                                    {  <->: Driver reference number }
  468.         ataDrvrFlags:            UInt16;                                    {  -->: 1 = loader driver if ataPBDeviceID = -1 (PB2) }
  469.         ataDeviceNextID:        UInt16;                                    {  <--: used to specified the next drive ID }
  470.         ataDrvrLoadPriv:        SInt16;                                    {  Driver loader private storage }
  471.         ataEventHandler:        ATAClientUPP;                            {  <->: Pointer to ATA event callback routine (PB2) }
  472.         ataDrvrContext:            SInt32;                                    {  <->: Context data saved by driver (PB2) }
  473.         ataEventMask:            SInt32;                                    {  <->: Set to 1 for notification of event (PB2) }
  474.         Reserved:                ARRAY [0..13] OF SInt16;                {  Reserved for future expansion - from [21] (PB2) }
  475.     END;
  476.  
  477. {  Parameter block structure for Modify driver event mask command }
  478.     ataModifyEventMaskPtr = ^ataModifyEventMask;
  479.     ataModifyEventMask = RECORD
  480.                                                                         {  Start of cloned common header ataPBHdr }
  481.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  482.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  483.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  484.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  485.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  486.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  487.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  488.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  489.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  490.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  491.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  492.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  493.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  494.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  495.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  496.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  497.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  498.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  499.                                                                         {  End of cloned common header ataPBHdr }
  500.         ataModifiedEventMask:    SInt32;                                    {  -->: new event mask value }
  501.         Reserved:                ARRAY [0..21] OF SInt16;                {  Reserved for future expansion }
  502.     END;
  503.  
  504. {  'ataRegMask' field of the ataRegAccess definition }
  505.  
  506. CONST
  507.     bATAAltSDevCValid            = 14;                            {  bit number of alternate status/device cntrl valid bit }
  508.     bATAStatusCmdValid            = 7;                            {  bit number of status/command valid bit }
  509.     bATASDHValid                = 6;                            {  bit number of ataTFSDH valid bit }
  510.     bATACylinderHiValid            = 5;                            {  bit number of cylinder high valid bit }
  511.     bATACylinderLoValid            = 4;                            {  bit number of cylinder low valid bit }
  512.     bATASectorNumValid            = 3;                            {  bit number of sector number valid bit }
  513.     bATASectorCntValid            = 2;                            {  bit number of sector count valid bit }
  514.     bATAErrFeaturesValid        = 1;                            {  bit number of error/features valid bit }
  515.     bATADataValid                = 0;                            {  bit number of data valid bit }
  516.     mATAAltSDevCValid            = $4000;                        {  alternate status/device control valid }
  517.     mATAStatusCmdValid            = $80;                            {  status/command valid }
  518.     mATASDHValid                = $40;                            {  ataTFSDH valid }
  519.     mATACylinderHiValid            = $20;                            {  cylinder high valid }
  520.     mATACylinderLoValid            = $10;                            {  cylinder low valid }
  521.     mATASectorNumValid            = $08;                            {  sector number valid }
  522.     mATASectorCntValid            = $04;                            {  sector count valid }
  523.     mATAErrFeaturesValid        = $02;                            {  error/features valid }
  524.     mATADataValid                = $01;                            {  data valid }
  525.  
  526. {  Parameter block structure for device register access command }
  527.  
  528. TYPE
  529.     ataRegValueUnionPtr = ^ataRegValueUnion;
  530.     ataRegValueUnion = RECORD
  531.         CASE INTEGER OF
  532.         0: (
  533.             ataByteRegValue:    SInt8;                                    {  <->: Byte register value read or to be written }
  534.             );
  535.         1: (
  536.             ataWordRegValue:    UInt16;                                    {  <->: Word register value read or to be written }
  537.             );
  538.     END;
  539.  
  540. {  Manager parameter block structure }
  541.     ataRegAccessPtr = ^ataRegAccess;
  542.     ataRegAccess = RECORD
  543.                                                                         {  Start of cloned common header ataPBHdr }
  544.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  545.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  546.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  547.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  548.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  549.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  550.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  551.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  552.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  553.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  554.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  555.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  556.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  557.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  558.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  559.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  560.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  561.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  562.                                                                         {  End of cloned common header ataPBHdr }
  563.         ataRegSelect:            UInt16;                                    {  -->: Device Register Selector }
  564.                                                                         {             DataReg            0     }
  565.                                                                         {             ErrorReg(R) or FeaturesReg(W)    1 }
  566.                                                                         {             SecCntReg        2 }
  567.                                                                         {             SecNumReg        3 }
  568.                                                                         {             CylLoReg        4 }
  569.                                                                         {             CylHiReg        5 }
  570.                                                                         {             SDHReg            6 }
  571.                                                                         {             StatusReg(R) or CmdReg(W)        7 }
  572.                                                                         {             AltStatus(R) or DevCntr(W)    0E }
  573.         ataRegValue:            ataRegValueUnion;
  574.                                                                         {  Following fields are valid only if ataRegSelect = 0xFFFF }
  575.         ataRegMask:                UInt16;                                    {  -->: mask for register(s) to update }
  576.                                                                         {         bit 0 : data register valid }
  577.                                                                         {         bit 1 : error/feaures register valid }
  578.                                                                         {         bit 2 : sector count register valid }
  579.                                                                         {         bit 3 : sector number register valid }
  580.                                                                         {         bit 4 : cylinder low register valid }
  581.                                                                         {         bit 5 : cylinder high register valid }
  582.                                                                         {         bit 6 : ataTFSDH register valid }
  583.                                                                         {         bit 7 : status/command register valid }
  584.                                                                         {         bits 8 - 13 : reserved (set to 0) }
  585.                                                                         {         bit 14: alternate status / device control reg valid }
  586.                                                                         {          bit 15: reserved (set to 0) }
  587.         ataRegisterImage:        ataTaskFile;                            {  <->: register images }
  588.         ataAltSDevCReg:            SInt8;                                    {  <->: Alternate status(R) or Device Control(W) register image }
  589.         Reserved3:                SInt8;                                    {  Reserved }
  590.         Reserved:                ARRAY [0..15] OF SInt16;                {  Reserved for future expansion }
  591.     END;
  592.  
  593. {  Manager parameter block structure    <DP03/10/94> }
  594.     ataIdentifyPtr = ^ataIdentify;
  595.     ataIdentify = RECORD
  596.                                                                         {  Start of cloned common header ataPBHdr }
  597.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  598.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  599.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  600.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  601.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  602.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  603.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  604.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  605.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  606.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  607.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  608.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  609.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  610.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  611.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  612.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  613.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  614.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  615.                                                                         {  End of cloned common header ataPBHdr }
  616.         Reserved1:                ARRAY [0..3] OF UInt16;                    {  Reserved.  These are used internally by the Manager }
  617.         ataPBBuffer:            Ptr;                                    {  Buffer for the identify data (512 bytes) }
  618.         Reserved2:                ARRAY [0..11] OF UInt16;                {  Used internally by the ATA Manager }
  619.         Reserved3:                ARRAY [0..5] OF SInt16;                    {  Reserved for future expansion }
  620.     END;
  621.  
  622. {  'ataConfigSetting' field of the Get/Set Device Configuration definition <8/6/94> }
  623.  
  624. CONST
  625.     ATAPIpacketDRQ_bit            = 6;                            {  bit number of ATAPI command packet DRQ option }
  626.     ATAPIpacketDRQ                = $40;                            {  ATAPI command packet DRQ option }
  627.  
  628. {  atapcValid field definition }
  629.     bATApcAccessMode            = 0;
  630.     bATApcVcc                    = 1;
  631.     bATApcVpp1                    = 2;
  632.     bATApcVpp2                    = 3;
  633.     bATApcStatus                = 4;
  634.     bATApcPin                    = 5;
  635.     bATApcCopy                    = 6;
  636.     bATApcConfigIndex            = 7;
  637.     bATApcLockUnlock            = 15;
  638.     mATApcAccessMode            = $01;
  639.     mATApcVcc                    = $02;
  640.     mATApcVpp1                    = $04;
  641.     mATApcVpp2                    = $08;
  642.     mATApcStatus                = $10;
  643.     mATApcPin                    = $20;
  644.     mATApcCopy                    = $40;
  645.     mATApcConfigIndex            = $80;
  646.     mATApcLockUnlock            = $8000;
  647.  
  648. {  Device physical type & socket type indicator definition }
  649.     kATADeviceUnknown            = $00;                            {  no device or type undetermined }
  650.     kATADeviceATA                = $01;                            {  traditional ATA protocol device <7/29/94> }
  651.     kATADeviceATAPI                = $02;                            {  ATAPI protocol device    <7/29/94> }
  652.     kATADevicePCMCIA            = $03;                            {  PCMCIA ATA device        <7/29/94> }
  653.     kATASocketInternal            = $01;                            {  Internal ATA socket }
  654.     kATASocketMB                = $02;                            {  Media Bay socket }
  655.     kATASocketPCMCIA            = $03;                            {  PCMCIA socket }
  656.     kATAConfigReserved            = 7;                            {  number of reserved words at the end }
  657.  
  658. {
  659.  Get/Set Device Configuration parameter block structure <8/6/94>
  660.  Manager parameter block structure
  661. }
  662.  
  663. TYPE
  664.     ataDevConfigurationPtr = ^ataDevConfiguration;
  665.     ataDevConfiguration = RECORD
  666.                                                                         {  Start of cloned common header ataPBHdr }
  667.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  668.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  669.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  670.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  671.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  672.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  673.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  674.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  675.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  676.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  677.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  678.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  679.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  680.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  681.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  682.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  683.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  684.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  685.                                                                         {  End of cloned common header ataPBHdr }
  686.         ataConfigSetting:        SInt32;                                    {  <->: Configuration setting }
  687.                                                                         {       Bits 3 - 0: Reserved }
  688.                                                                         {       Bit 4: Reserved (allowLBAAccess) }
  689.                                                                         {       Bit 5: Reserved (allowRWMultiple) }
  690.                                                                         {       Bit 6: ATAPIpacketDRQ }
  691.                                                                         {         1 = Check for Interrupt DRQ on ATAPI command packet DRQ }
  692.                                                                         {         0 = Default: Check only for the assertion of command packet DRQ }
  693.                                                                         {       Bits 31 - 7: Reserved }
  694.         ataPIOSpeedMode:        SInt8;                                    {  <->: Device access speed in PIO Mode }
  695.         Reserved3:                SInt8;                                    {  Reserved to force word alignment }
  696.         atapcValid:                UInt16;                                    {  <->: Set when pcXXX fields are valid (atapcAccessMode - atapcConfigIndex) }
  697.                                                                         {         bit 0 - atapcAccessMode field valid, when set }
  698.                                                                         {         bit 1 - atapcVcc field valid, when set }
  699.                                                                         {         bit 2 - atapcVpp1 field valid, when set }
  700.                                                                         {         bit 3 - atapcVpp2 field valid, when set }
  701.                                                                         {         bit 4 - atapcStatus field valid, when set }
  702.                                                                         {         bit 5 - atapcPin field valid, when set }
  703.                                                                         {         bit 6 - atapcCopy field valid, when set }
  704.                                                                         {         bit 7 - atapcConfigIndex field valid, when set }
  705.                                                                         {         bits 14-8 - Reserved }
  706.                                                                         {         bit 15 - device lock/unlock request (write only) }
  707.         ataRWMultipleCount:        UInt16;                                    {  Reserved for future (not supported yet) }
  708.         ataSectorsPerCylinder:    UInt16;                                    {  Reserved for future (not supported yet) }
  709.         ataHeads:                UInt16;                                    {  Reserved for future (not supported yet) }
  710.         ataSectorsPerTrack:        UInt16;                                    {  Reserved for future (not supported yet) }
  711.         ataSocketNumber:        UInt16;                                    {  <--: Socket number used by the CardServices }
  712.                                                                         {         0xFF = socket number invalid (Not a CardServices device) }
  713.                                                                         {         other = socket number of the device }
  714.         ataSocketType:            SInt8;                                    {  <--: Specifies the socket type (get config only) }
  715.                                                                         {         00 = Unknown socket }
  716.                                                                         {          01 = Internal ATA bus }
  717.                                                                         {         02 = Media Bay }
  718.                                                                         {         03 = PCMCIA }
  719.         ataDeviceType:            SInt8;                                    {  <--: Specifies the device type (get config only) }
  720.                                                                         {         00 = Unknown device }
  721.                                                                         {         01 = standard ATA device (HD) }
  722.                                                                         {         02 = ATAPI device }
  723.                                                                         {         03 = PCMCIA ATA device }
  724.         atapcAccessMode:        SInt8;                                    {  <->: Access mode: Memory vs. I/O (PCMCIA only) }
  725.         atapcVcc:                SInt8;                                    {  <->: Voltage in tenths of a volt (PCMCIA only) }
  726.         atapcVpp1:                SInt8;                                    {  <->: Voltage in tenths of a volt (PCMCIA only) }
  727.         atapcVpp2:                SInt8;                                    {  <->: Voltage in tenths of a volt (PCMCIA only) }
  728.         atapcStatus:            SInt8;                                    {  <->: Card Status register setting (PCMCIA only) }
  729.         atapcPin:                SInt8;                                    {  <->: Card Pin register setting (PCMCIA only) }
  730.         atapcCopy:                SInt8;                                    {  <->: Card Socket/Copy register setting (PCMCIA only) }
  731.         atapcConfigIndex:        SInt8;                                    {  <->: Card Option register setting (PCMCIA only) }
  732.         ataSingleDMASpeed:        SInt8;                                    {  <->: Single Word DMA Timing Class }
  733.         ataMultiDMASpeed:        SInt8;                                    {  <->: Multiple Word DMA Timing Class }
  734.         ataPIOCycleTime:        UInt16;                                    {  <->:Cycle time for PIO mode }
  735.         ataMultiCycleTime:        UInt16;                                    {  <->:Cycle time for Multiword DMA mode }
  736.         Reserved1:                ARRAY [0..6] OF UInt16;                    {  Reserved for future }
  737.     END;
  738.  
  739. {  Get Card Location Icon/Text    <SM4> }
  740.  
  741. CONST
  742.     kATALargeIconHFS            = $0001;                        {  Large B&W icon with mask (HFS) }
  743.     kATALargeIconProDOS            = $0081;                        {  Large B&W icon with mask (ProDOS) }
  744.  
  745. {  Manager parameter block structure }
  746.  
  747. TYPE
  748.     ataLocationDataPtr = ^ataLocationData;
  749.     ataLocationData = RECORD
  750.                                                                         {  Start of cloned common header ataPBHdr }
  751.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  752.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  753.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  754.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  755.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  756.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  757.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  758.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  759.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  760.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  761.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  762.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  763.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  764.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  765.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  766.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  767.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  768.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  769.                                                                         {  End of cloned common header ataPBHdr }
  770.         ataIconType:            SInt16;                                    {  -->: icon type specifier }
  771.                                                                         {          1 = Large B&W icon with mask (256 bytes) }
  772.                                                                         {         0x81 = Same as 1, but ProDOS icon }
  773.         ataIconReserved:        SInt16;                                    {  Reserved to be longword aligned }
  774.         ataLocationIconPtr:        Ptr;                                    {  -->: Icon Data buffer pointer }
  775.         ataLocationStringPtr:    Ptr;                                    {  -->: Icon String buffer pointer }
  776.         Reserved1:                ARRAY [0..17] OF UInt16;                {  Reserved for future }
  777.     END;
  778.  
  779. {  ataOSType available }
  780.  
  781. CONST
  782.     kATAddTypeMacOS                = $0001;                        {  Blue Mac O/S ddType value }
  783.  
  784. {  The parameter block definition for all other ATA Manager functions. }
  785.  
  786. TYPE
  787.     ataGenericPtr = ^ataGeneric;
  788.     ataGeneric = RECORD
  789.                                                                         {  Start of cloned common header ataPBHdr }
  790.         ataPBLink:                ataPBHeaderPtr;                            {  a pointer to the next entry in the queue     }
  791.         ataPBQType:                UInt16;                                    {  type byte for safety check }
  792.         ataPBVers:                SInt8;                                    {  -->: parameter block version number; Must be 0x01 }
  793.         ataPBReserved:            SInt8;                                    {  Reserved                                         }
  794.         ataPBReserved2:            Ptr;                                    {  Reserved                                         }
  795.         ataPBCallbackPtr:        ProcPtr;                                {  -->: Completion Routine Pointer     }
  796.         ataPBResult:            OSErr;                                    {  <--: Returned result                 }
  797.         ataPBFunctionCode:        SInt8;                                    {  -->: Manager Function Code  }
  798.         ataPBIOSpeed:            SInt8;                                    {  -->: I/O Timing Class             }
  799.         ataPBFlags:                UInt16;                                    {  -->: Various control options     }
  800.         ataPBReserved3:            SInt16;                                    {  Reserved                                         }
  801.         ataPBDeviceID:            UInt32;                                    {  -->: Device identifier             }
  802.         ataPBTimeOut:            UInt32;                                    {  -->: Transaction timeout value    in msec  }
  803.         ataPBClientPtr1:        Ptr;                                    {  Client's storage Ptr 1      }
  804.         ataPBClientPtr2:        Ptr;                                    {  Client's storage Ptr 2      }
  805.         ataPBState:                UInt16;                                    {  Reserved for Manager; Initialize to 0  }
  806.         ataPBSemaphores:        UInt16;                                    {  Used internally by the manager }
  807.         ataPBReserved4:            SInt32;                                    {  Reserved                                         }
  808.                                                                         {  End of cloned common header ataPBHdr }
  809.         Reserved:                ARRAY [0..23] OF UInt16;                {  Reserved for future }
  810.     END;
  811.  
  812.     ataPBPtr = ^ataPB;
  813.     ataPB = RECORD
  814.         CASE INTEGER OF
  815.         0: (
  816.             ataIOParamBlock:    ataIOPB;                                {  parameter block for I/O }
  817.             );
  818.         1: (
  819.             ataBIParamBlock:    ataBusInquiry;                            {  parameter block for bus inquiry }
  820.             );
  821.         2: (
  822.             ataMIParamBlock:    ataMgrInquiry;                            {  parameter block for Manager inquiry }
  823.             );
  824.         3: (
  825.             ataAbortParamBlock:    ataAbort;                                {  parameter block for abort }
  826.             );
  827.         4: (
  828.             ataDRParamBlock:    ataDrvrRegister;                        {  parameter block for driver register }
  829.             );
  830.         5: (
  831.             ataMEParamBlock:    ataModifyEventMask;                        {  parameter block for event mask modify }
  832.             );
  833.         6: (
  834.             ataRAParamBlock:    ataRegAccess;                            {  parameter block for register access }
  835.             );
  836.         7: (
  837.             ataDIParamBlock:    ataIdentify;                            {  parameter block for drive identify }
  838.             );
  839.         8: (
  840.             ataDCParamBlock:    ataDevConfiguration;                    {  parameter block for device configuration }
  841.             );
  842.         9: (
  843.             ataLDParamBlock:    ataLocationData;                        {  parameter block for location icon data }
  844.             );
  845.                                                                         { ataManagerInit    ataInitParamBlock;        // parameter block for Manager initialization }
  846.                                                                         { ataManagerShutDn    ataSDParamBlock;        // parameter block for Manager shutdown }
  847.                                                                         { ataDrvrLoad        ataDLParamBlock;        // parameter block for Driver loading }
  848.         10: (
  849.             ataGenericParamBlock: ataGeneric;                            {  parameter block for all other functions }
  850.             );
  851.     END;
  852.  
  853. {  The ATA Event codes… }
  854.  
  855. CONST
  856.     kATANullEvent                = $00;                            {  Just kidding -- nothing happened }
  857.     kATAOnlineEvent                = $01;                            {  An ATA device has come online }
  858.     kATAOfflineEvent            = $02;                            {  An ATA device has gone offline }
  859.     kATARemovedEvent            = $03;                            {  An ATA device has been removed from the bus }
  860.     kATAResetEvent                = $04;                            {  Someone gave a hard reset to the drive }
  861.     kATAOfflineRequest            = $05;                            {  Someone requesting to offline the drive }
  862.     kATAEjectRequest            = $06;                            {  Someone requesting to eject the drive }
  863.     kATAUpdateEvent                = $07;                            {  Potential configuration change reported by CardServices <SM4> }
  864.                                                                 {  The following describes bit definitions in the eventMask field of ataDrvrRegister }
  865.     bATANullEvent                = $01;                            {  null event bit }
  866.     bATAOnlineEvent                = $02;                            {  online event bit }
  867.     bATAOfflineEvent            = $04;                            {  offline event bit }
  868.     bATARemovedEvent            = $08;                            {  removed event bit }
  869.     bATAResetEvent                = $10;                            {  reset event bit }
  870.     bATAOfflineRequest            = $20;                            {  offline request event bit }
  871.     bATAEjectRequest            = $40;                            {  eject request event bit }
  872.     bATAUpdateEvent                = $80;                            {  configuration update event bit }
  873.  
  874.  
  875. TYPE
  876.     ATADispatchProcPtr = ProcPtr;  { FUNCTION ATADispatch(VAR pb: ataPB): OSErr; }
  877.  
  878.     ATADispatchUPP = UniversalProcPtr;
  879.  
  880. CONST
  881.     uppATADispatchProcInfo = $000000E0;
  882.  
  883. FUNCTION NewATADispatchProc(userRoutine: ATADispatchProcPtr): ATADispatchUPP;
  884.     {$IFC NOT GENERATINGCFM }
  885.     INLINE $2E9F;
  886.     {$ENDC}
  887.  
  888. FUNCTION CallATADispatchProc(VAR pb: ataPB; userRoutine: ATADispatchUPP): OSErr;
  889.     {$IFC NOT GENERATINGCFM}
  890.     INLINE $205F, $4E90;
  891.     {$ENDC}
  892. FUNCTION ataManager(VAR pb: ataPB): SInt16;
  893.     {$IFC NOT GENERATINGCFM}
  894.     INLINE $AAF1;
  895.     {$ENDC}
  896. {  Device Error codes: 0xDB42 - 0xDB5F     }
  897.  
  898. CONST
  899.     ATABaseErrCode                = -9406;                        {  Base error code - 0xDB42     }
  900.     ioPending                    = 1;                            {  Asynch I/O in progress status }
  901.     AT_NRdyErr                    = -9405;                        {  0xDB43: Drive not Ready  }
  902.     AT_IDNFErr                    = -9404;                        {  0xDB44: ID not found  }
  903.     AT_DMarkErr                    = -9403;                        {  0xDB45: Data mark not found  }
  904.     AT_BadBlkErr                = -9402;                        {  0xDB46: Bad Block  }
  905.     AT_CorDataErr                = -9401;                        {  0xDB47: Data was corrected  }
  906.     AT_UncDataErr                = -9400;                        {  0xDB48: Data was not corrected  }
  907.     AT_SeekErr                    = -9399;                        {  0xDB49: Seek error  }
  908.     AT_WrFltErr                    = -9398;                        {  0xDB4A: Write fault  }
  909.     AT_RecalErr                    = -9397;                        {  0xDB4B: Recalibrate failed  }
  910.     AT_AbortErr                    = -9396;                        {  0xDB4C: Command aborted by drive  }
  911.     AT_MCErr                    = -9394;                        {  0xDB4E: Media Changed error }
  912.     ATAPICheckErr                = -9393;                        {  0xDB4F: ATAPI Check condition <06/15/94> }
  913.                                                                 {  System error codes...Custom Driver Error Codes 0xDB60 - 0xDB6F }
  914.     DRVRCantAllocate            = -9376;                        {  0xDB60: Allocation error during initialization }
  915.     NoATAMgr                    = -9375;                        {  0xDB61: MgrInquiry failed => No ATA Manager }
  916.     ATAInitFail                    = -9374;                        {  0xDB62: Mgr Initialization failed }
  917.     ATABufFail                    = -9373;                        {  0xDB63: Device buffer test failure }
  918.     ATADevUnsupported            = -9372;                        {  0xDB64: Device type not supported }
  919.     ATAEjectDrvErr                = -9371;                        {  0xDB65: Could not eject the drive }
  920.                                                                 {  Manager Error Codes 0xDB70 - 0xDB8F }
  921.     ATAMgrNotInitialized        = -9360;                        {  0xDB70: Mgr has not been initialized }
  922.     ATAPBInvalid                = -9359;                        {  0xDB71: The bus base address couldn't be found }
  923.     ATAFuncNotSupported            = -9358;                        {  0xDB72: An unknown function code specified }
  924.     ATABusy                        = -9357;                        {  0xDB73: Selected device is busy }
  925.     ATATransTimeOut                = -9356;                        {  0xDB74: Transaction timeout detected }
  926.     ATAReqInProg                = -9355;                        {  0xDB75: Channel busy; channel is processing another cmd }
  927.     ATAUnknownState                = -9354;                        {  0xDB76: Device status register reflects an unknown state }
  928.     ATAQLocked                    = -9353;                        {  0xDB77: I/O Queue is locked due to previous I/O error. }
  929.     ATAReqAborted                = -9352;                        {  0xDB78: The I/O queue entry was aborted due to an abort req. }
  930.                                                                 {             or due to Manager shutdown. }
  931.     ATAUnableToAbort            = -9351;                        {  0xDB79: The I/O queue entry could not be aborted. }
  932.     ATAAbortedDueToRst            = -9350;                        {  0xDB7A: Request aborted due to a device reset command. }
  933.     ATAPIPhaseErr                = -9349;                        {  0xDB7B: Unexpected phase - •••IS THIS VALID ERROR??? <06/15/94> }
  934.     ATAPITxCntErr                = -9348;                        {  0xDB7C: Overrun/Underrun condition detected }
  935.     ATANoClientErr                = -9347;                        {  0xDB7D: No client present to handle the event }
  936.     ATAInternalErr                = -9346;                        {  0xDB7E: MagnumOpus returned an error }
  937.     ATABusErr                    = -9345;                        {  0xDB7F: Bus error detected on I/O     }
  938.     AT_NoAddrErr                = -9344;                        {  0xDB80: Invalid AT base adress  }
  939.     DriverLocked                = -9343;                        {  0xDB81: Current driver must be removed before adding another }
  940.     CantHandleEvent                = -9342;                        {  0xDB82: Particular event couldn't be handled (call others) }
  941.     ATAMgrMemoryErr                = -9341;                        {  0xDB83: Manager memory allocation error     }
  942.     ATASDFailErr                = -9340;                        {  0xDB84: Shutdown failure                 }
  943.     ATAXferParamErr                = -9339;                        {  0xDB85: I/O xfer parameters inconsistent  }
  944.     ATAXferModeErr                = -9338;                        {  0xDB86: I/O xfer mode not supported  }
  945.     ATAMgrConsistencyErr        = -9337;                        {  0XDB87: Manager detected internal inconsistency.  }
  946.     ATADmaXferErr                = -9336;                        {  0XDB88: fatal error in DMA side of transfer  }
  947.                                                                 {  Driver loader error Codes 0xDB90 - 0xDBA5 }
  948.     ATAInvalidDrvNum            = -9328;                        {  0xDB90: Invalid drive number from event }
  949.     ATAMemoryErr                = -9327;                        {  0xDB91: Memory allocation error }
  950.     ATANoDDMErr                    = -9326;                        {  0xDB92: No DDM found on media     }
  951.     ATANoDriverErr                = -9325;                        {  0xDB93: No driver found on the media     }
  952.  
  953. {  ------------------------    Version 1 definition -------------------------------     }
  954.     v1ATABaseErrCode            = $0700;                        {  This needs a home somewhere }
  955.     v1AT_NRdyErr                = $FFFFF901;                    {  0xF901: -0x1DBE  }
  956.     v1AT_IDNFErr                = $FFFFF904;                    {  0xF904: -0x1DC0  }
  957.     v1AT_DMarkErr                = $FFFFF905;                    {  0xF905: -0x1DC0  }
  958.     v1AT_BadBlkErr                = $FFFFF906;                    {  0xF906: -0x1DC0  }
  959.     v1AT_CorDataErr                = $FFFFF907;                    {  0xF907: -0x1DC0  }
  960.     v1AT_UncDataErr                = $FFFFF908;                    {  0xF908: -0x1DC0  }
  961.     v1AT_SeekErr                = $FFFFF909;                    {  0xF909: -0x1DC0  }
  962.     v1AT_WrFltErr                = $FFFFF90A;                    {  0xF90A: -0x1DC0  }
  963.     v1AT_RecalErr                = $FFFFF90B;                    {  0xF90B: -0x1DC0  }
  964.     v1AT_AbortErr                = $FFFFF90C;                    {  0xF90C: -0x1DC0  }
  965.     v1AT_NoAddrErr                = $FFFFF90D;                    {  0xF90D: -0x1D8D  }
  966.     v1AT_MCErr                    = $FFFFF90E;                    {  0xF90E: -0x1DC0 }
  967.                                                                 {  System error codes...Custom Driver Error Codes }
  968.     v1DRVRCantAllocate            = -1793;                        {  0xF8FF: -0x1D9F }
  969.     v1NoATAMgr                    = -1794;                        {  0xF8FE: -0x1D9D }
  970.     v1ATAInitFail                = -1795;                        {  0xF8FD: -0x1D9B }
  971.     v1ATABufFail                = -1796;                        {  0xF8FC: -0x1D99 }
  972.     v1ATADevUnsupported            = -1797;                        {  0xF8FB: -0x1c97 }
  973.                                                                 {  Manager Error Codes }
  974.     v1ATAMgrNotInitialized        = -1802;                        {  0xF8F6: -0x1D86 }
  975.     v1ATAPBInvalid                = -1803;                        {  0xF8F5: -0x1D84 }
  976.     v1ATAFuncNotSupported        = -1804;                        {  0xF8F4: -0x1D82 }
  977.     v1ATABusy                    = -1805;                        {  0xF8F3: -0x1D80 }
  978.     v1ATATransTimeOut            = -1806;                        {  0xF8F2: -0x1D7E }
  979.     v1ATAReqInProg                = -1807;                        {  0xF8F1: -0x1D7C }
  980.     v1ATAUnknownState            = -1808;                        {  0xF8F0: -0x1D7A }
  981.     v1ATAQLocked                = -1809;                        {  0xF8EF: -0x1D78 }
  982.     v1ATAReqAborted                = -1810;                        {  0xF8EE: -0x1D76 }
  983.     v1ATAUnableToAbort            = -1811;                        {  0xF8ED: -0x1D74 }
  984.     v1ATAAbortedDueToRst        = -1812;                        {  0xF8EC: -0x1D72 }
  985.  
  986. {$ALIGN RESET}
  987. {$POP}
  988.  
  989. {$SETC UsingIncludes := ATAIncludes}
  990.  
  991. {$ENDC} {__ATA__}
  992.  
  993. {$IFC NOT UsingIncludes}
  994.  END.
  995. {$ENDC}
  996.